package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmQuotaRetrunDao;
import com.jy.modules.cims.data.common.dto.TCMmQuotaRetrunDTO;
import com.jy.modules.cims.data.dao.CreditImageInformationDao;
import com.jy.modules.cims.data.dto.PlcImagesDto;
import com.jy.modules.cims.data.dto.credit.CreditImageInformationDto;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmQuotaRetrunService
 * @description: 定义  T_C_MM_QUOTA_RETRUN 实现类
 * @author:  JY-IT-D001
 */
@Service("com.jy.modules.cims.component.common.service.TCMmQuotaRetrunService")
public class TCMmQuotaRetrunService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmQuotaRetrunDao dao;
	
	@Autowired
	private CreditImageInformationDao creditImageInformation;

	/**
     * @author JY-IT-D001
     * @description: 分页查询 T_C_MM_QUOTA_RETRUN列表
     * @date 2015-01-09 09:48:03
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmQuotaRetrunDTO> searchTCMmQuotaRetrunByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmQuotaRetrunDTO> dataList =  dao.searchTCMmQuotaRetrunByPaging(searchParams);
		return dataList;
	}
	/**
     * @author JY-IT-D001
     * @description: 按条件查询T_C_MM_QUOTA_RETRUN列表
     * @date 2015-01-09 09:48:03
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmQuotaRetrunDTO> searchTCMmQuotaRetrun(Map<String,Object> searchParams) throws Exception {
	    List<TCMmQuotaRetrunDTO> dataList = dao.searchTCMmQuotaRetrun(searchParams);
        return dataList;
    }
	/**
     * @author JY-IT-D001
     * @description: 查询T_C_MM_QUOTA_RETRUN对象
     * @date 2015-01-09 09:48:03
     * @param id
     * @return
     * @throws
     */ 
	public TCMmQuotaRetrunDTO queryTCMmQuotaRetrunByPrimaryKey(String id) throws Exception {
		
		TCMmQuotaRetrunDTO dto = dao.findTCMmQuotaRetrunByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmQuotaRetrunDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmQuotaRetrun
     * @author JY-IT-D001
     * @description: 新增 T_C_MM_QUOTA_RETRUN对象
     * @date 2015-01-09 09:48:03
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmQuotaRetrun(TCMmQuotaRetrunDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmQuotaRetrun(paramMap);
		
		TCMmQuotaRetrunDTO resultDto = (TCMmQuotaRetrunDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	
	/**
	 * 通过机构编号获取影响类型 :机构编号，业务类型，贷款类型
	 * @param cooperorgCode
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("all")
	public List<CreditImageInformationDto> queryDataByCooperorgCode(String cooperorgCode,String dealType,String productType) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		CreditImageInformationDto dto = new CreditImageInformationDto();
		dto.setCooperorgCode(cooperorgCode);
		dto.setProductType(productType);
		dto.setDealType(dealType);
		paramMap.put("dto", dto);
		
		List<CreditImageInformationDto> resultList = creditImageInformation.queryDataByCooperorgCode(paramMap);
		
		return resultList;
	}
	/**
	 * 通过机构编号获取影响类型 :机构编号，业务类型，贷款类型
	 * @param cooperorgCode
	 * @return 格式：'A1,B1,N1'
	 * @throws Exception
	 */
	@SuppressWarnings("all")
	public List<CreditImageInformationDto> queryDataToWn(PlcImagesDto imgDto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		CreditImageInformationDto dto = new CreditImageInformationDto();
		dto.setCooperorgCode(imgDto.getCooperorgCode());
		dto.setProductType(imgDto.getProductType());
		dto.setDealType(imgDto.getDealType());
		dto.setProductCode(imgDto.getProductCode());
		paramMap.put("dto", dto);
		
		List<CreditImageInformationDto> resultList = creditImageInformation.queryDataToWn(paramMap);
		
		return resultList;
	}
	
	/**
     * @title: updateTCMmQuotaRetrun
     * @author JY-IT-D001
     * @description: 修改 T_C_MM_QUOTA_RETRUN对象
     * @date 2015-01-09 09:48:03
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmQuotaRetrun(TCMmQuotaRetrunDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmQuotaRetrun(paramMap);
	}
	/**
     * @title: deleteTCMmQuotaRetrunByPrimaryKey
     * @author JY-IT-D001
     * @description: 删除 T_C_MM_QUOTA_RETRUN,按主键
     * @date 2015-01-09 09:48:03
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmQuotaRetrunByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmQuotaRetrunByPrimaryKey(paramMap);
	}

}

